// redux 是一种数据管理模型 跟react没啥关系
// 想把redux 应用到 react中 必须借助 react-redux

import React from 'react';
import ReactDOM from 'react-dom';
import store from './store'
import {Provider,connect} from 'react-redux'
class App extends React.Component {

    render() {
        console.log(this.props)
        return <div className=''>
            <h1>当前数字是{this.props.count}</h1>
            <button onClick={this.props.add.bind(this,20)}>+</button>
            <button onClick={()=>{this.props.dispatch({type:'minus',num:10})}}>+</button>
        </div>;
    }
}
App = connect((state)=>{
  return {
    qqq:123,
    www:234,
    count:state.count
  }
},(dispatch)=>{
  return {
    add:(num)=>{
      dispatch({type:'add',num:num})
    },
    dispatch:dispatch
  }
})(App)

ReactDOM.render(<Provider store={store}>
  <App/>
</Provider>,document.getElementById('root'))
